package cn.tedu.springdemo.mapper;

import cn.tedu.springdemo.bean.User;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@Mapper
@CacheNamespace
public interface UserMapper {

    @Select("SELECT id, name FROM users")
    List<User> listUsers();

    @Select("SELECT id, name FROM users WHERE id=#{id}")
    User findUserById(Integer id);

    @Select("SELECT * FROM ${table}")
    List<Map<String, Object>> listAll(String table);

    @Insert("INSERT INTO users (id, name) VALUES (#{id}, '${name}')")
    Integer insertUser(User user);
}
